<template>
  <div class="newsDialog">
    <div v-if="types === 1">
      <vxe-table ref="treeTable"  resizable  row-id="id"  border highlight-hover-row  highlight-current-row  height="500"
      :data="tableDataList" header-align="center" @radio-change="radioChange" >
        <vxe-table-column type="radio" title="选择" width="50" align="center" />
        <vxe-table-column field="priTmplId" min-width="320" title="模板代码" />
        <vxe-table-column field="title" min-width="300" title="模板名称" />
      </vxe-table>
    </div>
    <div v-if="types === 2">
      <vxe-table ref="treeTable" resizable row-id="id" border highlight-hover-row highlight-current-row height="500"
        :data="tableDataList" header-align="center" @radio-change="radioChange" >
        <vxe-table-column type="radio" title="选择" width="50" align="center" />
        <vxe-table-column field="templateId" min-width="320" title="模板代码" />
        <vxe-table-column field="title" min-width="300" title="模板名称" />
      </vxe-table>
    </div>
    <div v-if="types === 3">
      <ImageTextMaterial ref="imgText" :bool="bool" @imgBox="imgBox" />
    </div>
    <div v-if="types === 4">
      <vxe-table ref="treeTable" resizable row-id="id" border highlight-hover-row  highlight-current-row height="500"
        :data="tableDataList" header-align="center" @radio-change="radioChange" >
        <vxe-table-column type="radio" title="选择" width="50" align="center" />
        <vxe-table-column field="templateCode" min-width="150" title="模板代码" />
        <vxe-table-column field="templateName" min-width="200" title="模板名称" />
      </vxe-table>
    </div>
    <div v-if="types === 5">
      <vxe-table ref="treeTable" resizable row-id="id" border highlight-hover-row  highlight-current-row height="500"
        :data="tableDataList" header-align="center" @radio-change="radioChange" >
        <vxe-table-column type="radio" title="选择" width="50" align="center" />
        <vxe-table-column field="templateCode" min-width="150" title="模板代码" />
        <vxe-table-column field="templateName" min-width="200" title="模板名称" />
      </vxe-table>
    </div>
    <div v-if="types === 6">
      <vxe-table ref="treeTable" resizable row-id="id" border highlight-hover-row  highlight-current-row height="500"
        :data="tableDataList" header-align="center" @radio-change="radioChange" >
        <vxe-table-column type="radio" title="选择" width="50" align="center" />
        <vxe-table-column field="templateCode" min-width="150" title="模板代码" />
        <vxe-table-column field="templateName" min-width="200" title="模板名称" />
      </vxe-table>
    </div>
    <div v-if="types === 7">
      <vxe-table ref="treeTable" resizable row-id="id" border highlight-hover-row  highlight-current-row height="500"
        :data="tableDataList" header-align="center" @radio-change="radioChange" >
        <vxe-table-column type="radio" title="选择" width="50" align="center" />
        <vxe-table-column field="templateId" min-width="150" title="模板代码" />
        <vxe-table-column field="title" min-width="200" title="模板名称" />
      </vxe-table>
    </div>
  </div>
</template>
<script>
import { queryWxMaMsgTemplateList, queryWxMpMsgTemplateList, queryWxCpMsgTemplateList,
listEffectSmsTemplateByDefaultConfig, listEffectEmailTemplate, listEffectSysMsgTemplate } from '@/api/messageSetting'
export default {
  components: {
    ImageTextMaterial: () => import('@/views/wxMp/components/imageTextMediaSource.vue')
  },
  props: {
    types: {
      type: Number,
      default: 1
    },
    receiverType: {
      type: Number,
      default: 3
    }
  },
  data() {
    return {
      tableDataList: [],
      params: {},
      bool: false
    }
  },
  mounted() {
    this.getList()
  },
  methods: {
    // 列表:
    getList() {
      switch (this.types) {
        case 1:
          //小程序订阅号模板消息
          queryWxMaMsgTemplateList(this.params).then(res => {
            this.tableDataList = res
          })
          break
        case 2:
          //公众号模板消息
          queryWxMpMsgTemplateList({...this.params}).then(res => {
            this.tableDataList = res
          })
          break
        case 3:
          //公众号图文消息
          listMediaSource({ ...this.params, sourceType: 'IMAGE_TEXT' }).then(res => {
            this.tableDataList = res
          })
          break
        case 4:
          //短信模板消息
          listEffectSmsTemplateByDefaultConfig().then(res => {
            this.tableDataList = res
          })
          break
        case 5:
          //邮件模板消息
          listEffectEmailTemplate({}).then(res => {
            this.tableDataList = res
          })
          break
        case 6:
          //系统模板消息
          listEffectSysMsgTemplate({receiverType: this.receiverType }).then(res => {
            this.tableDataList = res
          })
          break
        case 7:
          //企业微信消息
          queryWxCpMsgTemplateList({...this.params}).then(res => {
            this.tableDataList = res
          })
      }
    },
    // 单选框
    radioChange({ row }) {
      this.$emit('selectedRow', row)
    },
    imgBox(row) {
      this.$emit('selectedRow', row)
    }
  }
}
</script>
<style lang="scss" scoped>

</style>
